<?php
/**
 * 描述：交易频道-供应信息页。
 * @final
 */
final class Exec_Transaction_Supply_Info extends Exec
{
    public function Get()
    {
        #获取参数
        $id=Functions::UrlArgs('id');
        if(!is_numeric($id))
        {
            echo 'error';
            return;
        }

        #获取供应信息数据
        $supply=DB::GetRowByID('supply',$id);
        if($supply)
        {
            $supply['ThumbnailPath']=Config::PATH_RELATIVE_ATTACHMENT_SUPPLY.'/'.$supply['ThumbnailPath'];
            $supply['ClassName']=DAO_Category::GetNameByID($supply['ClassID']);
            $supply['SubclassName']=DAO_Category::GetNameByID($supply['SubclassID']);
            View::Assign('Supply',$supply);
        }
        else
        {
            echo 'error:supply';
            return;
        }

        #account
        $account=DB::PGetRows('select * from account where Username=?',array($supply['Account']));
        if($account)
        {
            //是否VIP会员
            $tmp=DB::PGetRows('select * from account_vip where Account=? limit 0,1',array($account[0]['Username']));
            $account[0]['IsVip']='FALSE';
            if($tmp){
                $account[0]['IsVip']='TRUE';
            }            
        }
        View::Assign('Account',@$account[0]);
        
        #获取相同用户相同类别的供应信息数据
        $supplies=DB::PGetRows('select * from supply where Account=? and ClassID=? and SubclassID=? and ID<>? order by ID desc limit 0,5',array(
            $supply['Account'],
            $supply['ClassID'],
            $supply['SubclassID'],
            $id
        ));
        View::Assign('Supplies',$supplies);

        #渲染输出        
        View::Display('transaction/supply/info.tpl');
    }
}
?>